// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate gtype;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate rpc;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A guest attributes.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GuestAttributes {
    /// The path to be queried. This can be the default namespace ('/') or a
    /// nested namespace ('/\<namespace\>/') or a specified key
    /// ('/\<namespace\>/\<key\>')
    pub query_path: std::string::String,

    /// The value of the requested queried path.
    pub query_value: std::option::Option<crate::model::GuestAttributesValue>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GuestAttributes {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [query_path][crate::model::GuestAttributes::query_path].
    pub fn set_query_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.query_path = v.into();
        self
    }

    /// Sets the value of [query_value][crate::model::GuestAttributes::query_value].
    pub fn set_query_value<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::GuestAttributesValue>,
    {
        self.query_value = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [query_value][crate::model::GuestAttributes::query_value].
    pub fn set_or_clear_query_value<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::GuestAttributesValue>,
    {
        self.query_value = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for GuestAttributes {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GuestAttributes"
    }
}

/// Array of guest attribute namespace/key/value tuples.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GuestAttributesValue {
    /// The list of guest attributes entries.
    pub items: std::vec::Vec<crate::model::GuestAttributesEntry>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GuestAttributesValue {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [items][crate::model::GuestAttributesValue::items].
    pub fn set_items<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::GuestAttributesEntry>,
    {
        use std::iter::Iterator;
        self.items = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for GuestAttributesValue {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GuestAttributesValue"
    }
}

/// A guest attributes namespace/key/value entry.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GuestAttributesEntry {
    /// Namespace for the guest attribute entry.
    pub namespace: std::string::String,

    /// Key for the guest attribute entry.
    pub key: std::string::String,

    /// Value for the guest attribute entry.
    pub value: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GuestAttributesEntry {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [namespace][crate::model::GuestAttributesEntry::namespace].
    pub fn set_namespace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.namespace = v.into();
        self
    }

    /// Sets the value of [key][crate::model::GuestAttributesEntry::key].
    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.key = v.into();
        self
    }

    /// Sets the value of [value][crate::model::GuestAttributesEntry::value].
    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.value = v.into();
        self
    }
}

impl wkt::message::Message for GuestAttributesEntry {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GuestAttributesEntry"
    }
}

/// A node-attached disk resource.
/// Next ID: 8;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AttachedDisk {
    /// Specifies the full path to an existing disk.
    /// For example: "projects/my-project/zones/us-central1-c/disks/my-disk".
    pub source_disk: std::string::String,

    /// The mode in which to attach this disk.
    /// If not specified, the default is READ_WRITE mode.
    /// Only applicable to data_disks.
    pub mode: crate::model::attached_disk::DiskMode,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AttachedDisk {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [source_disk][crate::model::AttachedDisk::source_disk].
    pub fn set_source_disk<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.source_disk = v.into();
        self
    }

    /// Sets the value of [mode][crate::model::AttachedDisk::mode].
    pub fn set_mode<T: std::convert::Into<crate::model::attached_disk::DiskMode>>(
        mut self,
        v: T,
    ) -> Self {
        self.mode = v.into();
        self
    }
}

impl wkt::message::Message for AttachedDisk {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.AttachedDisk"
    }
}

/// Defines additional types related to [AttachedDisk].
pub mod attached_disk {
    #[allow(unused_imports)]
    use super::*;

    /// The different mode of the attached disk.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum DiskMode {
        /// The disk mode is not known/set.
        Unspecified,
        /// Attaches the disk in read-write mode. Only one TPU node can attach a disk
        /// in read-write mode at a time.
        ReadWrite,
        /// Attaches the disk in read-only mode. Multiple TPU nodes can attach
        /// a disk in read-only mode at a time.
        ReadOnly,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [DiskMode::value] or
        /// [DiskMode::name].
        UnknownValue(disk_mode::UnknownValue),
    }

    #[doc(hidden)]
    pub mod disk_mode {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl DiskMode {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::ReadWrite => std::option::Option::Some(1),
                Self::ReadOnly => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("DISK_MODE_UNSPECIFIED"),
                Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
                Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for DiskMode {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for DiskMode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for DiskMode {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::ReadWrite,
                2 => Self::ReadOnly,
                _ => Self::UnknownValue(disk_mode::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for DiskMode {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "DISK_MODE_UNSPECIFIED" => Self::Unspecified,
                "READ_WRITE" => Self::ReadWrite,
                "READ_ONLY" => Self::ReadOnly,
                _ => Self::UnknownValue(disk_mode::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for DiskMode {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::ReadWrite => serializer.serialize_i32(1),
                Self::ReadOnly => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for DiskMode {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<DiskMode>::new(
                ".google.cloud.tpu.v2.AttachedDisk.DiskMode",
            ))
        }
    }
}

/// Sets the scheduling options for this node.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SchedulingConfig {
    /// Defines whether the node is preemptible.
    pub preemptible: bool,

    /// Whether the node is created under a reservation.
    pub reserved: bool,

    /// Optional. Defines whether the node is Spot VM.
    pub spot: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SchedulingConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [preemptible][crate::model::SchedulingConfig::preemptible].
    pub fn set_preemptible<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.preemptible = v.into();
        self
    }

    /// Sets the value of [reserved][crate::model::SchedulingConfig::reserved].
    pub fn set_reserved<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.reserved = v.into();
        self
    }

    /// Sets the value of [spot][crate::model::SchedulingConfig::spot].
    pub fn set_spot<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.spot = v.into();
        self
    }
}

impl wkt::message::Message for SchedulingConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.SchedulingConfig"
    }
}

/// A network endpoint over which a TPU worker can be reached.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct NetworkEndpoint {
    /// The internal IP address of this network endpoint.
    pub ip_address: std::string::String,

    /// The port of this network endpoint.
    pub port: i32,

    /// The access config for the TPU worker.
    pub access_config: std::option::Option<crate::model::AccessConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl NetworkEndpoint {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [ip_address][crate::model::NetworkEndpoint::ip_address].
    pub fn set_ip_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.ip_address = v.into();
        self
    }

    /// Sets the value of [port][crate::model::NetworkEndpoint::port].
    pub fn set_port<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.port = v.into();
        self
    }

    /// Sets the value of [access_config][crate::model::NetworkEndpoint::access_config].
    pub fn set_access_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::AccessConfig>,
    {
        self.access_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [access_config][crate::model::NetworkEndpoint::access_config].
    pub fn set_or_clear_access_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::AccessConfig>,
    {
        self.access_config = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for NetworkEndpoint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.NetworkEndpoint"
    }
}

/// An access config attached to the TPU worker.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AccessConfig {
    /// Output only. An external IP address associated with the TPU worker.
    pub external_ip: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AccessConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [external_ip][crate::model::AccessConfig::external_ip].
    pub fn set_external_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.external_ip = v.into();
        self
    }
}

impl wkt::message::Message for AccessConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.AccessConfig"
    }
}

/// Network related configurations.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct NetworkConfig {
    /// The name of the network for the TPU node. It must be a preexisting Google
    /// Compute Engine network. If none is provided, "default" will be used.
    pub network: std::string::String,

    /// The name of the subnetwork for the TPU node. It must be a preexisting
    /// Google Compute Engine subnetwork. If none is provided, "default" will be
    /// used.
    pub subnetwork: std::string::String,

    /// Indicates that external IP addresses would be associated with the TPU
    /// workers. If set to false, the specified subnetwork or network should have
    /// Private Google Access enabled.
    pub enable_external_ips: bool,

    /// Allows the TPU node to send and receive packets with non-matching
    /// destination or source IPs. This is required if you plan to use the TPU
    /// workers to forward routes.
    pub can_ip_forward: bool,

    /// Optional. Specifies networking queue count for TPU VM instance's network
    /// interface.
    pub queue_count: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl NetworkConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [network][crate::model::NetworkConfig::network].
    pub fn set_network<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.network = v.into();
        self
    }

    /// Sets the value of [subnetwork][crate::model::NetworkConfig::subnetwork].
    pub fn set_subnetwork<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.subnetwork = v.into();
        self
    }

    /// Sets the value of [enable_external_ips][crate::model::NetworkConfig::enable_external_ips].
    pub fn set_enable_external_ips<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.enable_external_ips = v.into();
        self
    }

    /// Sets the value of [can_ip_forward][crate::model::NetworkConfig::can_ip_forward].
    pub fn set_can_ip_forward<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.can_ip_forward = v.into();
        self
    }

    /// Sets the value of [queue_count][crate::model::NetworkConfig::queue_count].
    pub fn set_queue_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.queue_count = v.into();
        self
    }
}

impl wkt::message::Message for NetworkConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.NetworkConfig"
    }
}

/// A service account.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ServiceAccount {
    /// Email address of the service account. If empty, default Compute service
    /// account will be used.
    pub email: std::string::String,

    /// The list of scopes to be made available for this service account. If empty,
    /// access to all Cloud APIs will be allowed.
    pub scope: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ServiceAccount {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [email][crate::model::ServiceAccount::email].
    pub fn set_email<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.email = v.into();
        self
    }

    /// Sets the value of [scope][crate::model::ServiceAccount::scope].
    pub fn set_scope<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.scope = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ServiceAccount {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ServiceAccount"
    }
}

/// A TPU instance.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Node {
    /// Output only. Immutable. The name of the TPU.
    pub name: std::string::String,

    /// The user-supplied description of the TPU. Maximum of 512 characters.
    pub description: std::string::String,

    /// Optional. The type of hardware accelerators associated with this node.
    pub accelerator_type: std::string::String,

    /// Output only. The current state for the TPU Node.
    pub state: crate::model::node::State,

    /// Output only. If this field is populated, it contains a description of why
    /// the TPU Node is unhealthy.
    pub health_description: std::string::String,

    /// Required. The runtime version running in the Node.
    pub runtime_version: std::string::String,

    /// Network configurations for the TPU node. network_config and network_configs
    /// are mutually exclusive, you can only specify one of them. If both are
    /// specified, an error will be returned.
    pub network_config: std::option::Option<crate::model::NetworkConfig>,

    /// Optional. Repeated network configurations for the TPU node. This field is
    /// used to specify multiple networks configs for the TPU node. network_config
    /// and network_configs are mutually exclusive, you can only specify one of
    /// them. If both are specified, an error will be returned.
    pub network_configs: std::vec::Vec<crate::model::NetworkConfig>,

    /// The CIDR block that the TPU node will use when selecting an IP address.
    /// This CIDR block must be a /29 block; the Compute Engine networks API
    /// forbids a smaller block, and using a larger block would be wasteful (a
    /// node can only consume one IP address). Errors will occur if the CIDR block
    /// has already been used for a currently existing TPU node, the CIDR block
    /// conflicts with any subnetworks in the user's provided network, or the
    /// provided network is peered with another network that is using that CIDR
    /// block.
    pub cidr_block: std::string::String,

    /// The Google Cloud Platform Service Account to be used by the TPU node VMs.
    /// If None is specified, the default compute service account will be used.
    pub service_account: std::option::Option<crate::model::ServiceAccount>,

    /// Output only. The time when the node was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// The scheduling options for this node.
    pub scheduling_config: std::option::Option<crate::model::SchedulingConfig>,

    /// Output only. The network endpoints where TPU workers can be accessed and
    /// sent work. It is recommended that runtime clients of the node reach out
    /// to the 0th entry in this map first.
    pub network_endpoints: std::vec::Vec<crate::model::NetworkEndpoint>,

    /// The health status of the TPU node.
    pub health: crate::model::node::Health,

    /// Resource labels to represent user-provided metadata.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Custom metadata to apply to the TPU Node.
    /// Can set startup-script and shutdown-script
    pub metadata: std::collections::HashMap<std::string::String, std::string::String>,

    /// Tags to apply to the TPU Node. Tags are used to identify valid sources or
    /// targets for network firewalls.
    pub tags: std::vec::Vec<std::string::String>,

    /// Output only. The unique identifier for the TPU Node.
    pub id: i64,

    /// The additional data disks for the Node.
    pub data_disks: std::vec::Vec<crate::model::AttachedDisk>,

    /// Output only. The API version that created this Node.
    pub api_version: crate::model::node::ApiVersion,

    /// Output only. The Symptoms that have occurred to the TPU Node.
    pub symptoms: std::vec::Vec<crate::model::Symptom>,

    /// Shielded Instance options.
    pub shielded_instance_config: std::option::Option<crate::model::ShieldedInstanceConfig>,

    /// The AccleratorConfig for the TPU Node.
    pub accelerator_config: std::option::Option<crate::model::AcceleratorConfig>,

    /// Output only. The qualified name of the QueuedResource that requested this
    /// Node.
    pub queued_resource: std::string::String,

    /// Output only. Whether the Node belongs to a Multislice group.
    pub multislice_node: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Node {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Node::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::Node::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [accelerator_type][crate::model::Node::accelerator_type].
    pub fn set_accelerator_type<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.accelerator_type = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Node::state].
    pub fn set_state<T: std::convert::Into<crate::model::node::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [health_description][crate::model::Node::health_description].
    pub fn set_health_description<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.health_description = v.into();
        self
    }

    /// Sets the value of [runtime_version][crate::model::Node::runtime_version].
    pub fn set_runtime_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.runtime_version = v.into();
        self
    }

    /// Sets the value of [network_config][crate::model::Node::network_config].
    pub fn set_network_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::NetworkConfig>,
    {
        self.network_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [network_config][crate::model::Node::network_config].
    pub fn set_or_clear_network_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::NetworkConfig>,
    {
        self.network_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [network_configs][crate::model::Node::network_configs].
    pub fn set_network_configs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::NetworkConfig>,
    {
        use std::iter::Iterator;
        self.network_configs = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [cidr_block][crate::model::Node::cidr_block].
    pub fn set_cidr_block<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.cidr_block = v.into();
        self
    }

    /// Sets the value of [service_account][crate::model::Node::service_account].
    pub fn set_service_account<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ServiceAccount>,
    {
        self.service_account = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [service_account][crate::model::Node::service_account].
    pub fn set_or_clear_service_account<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ServiceAccount>,
    {
        self.service_account = v.map(|x| x.into());
        self
    }

    /// Sets the value of [create_time][crate::model::Node::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Node::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [scheduling_config][crate::model::Node::scheduling_config].
    pub fn set_scheduling_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::SchedulingConfig>,
    {
        self.scheduling_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [scheduling_config][crate::model::Node::scheduling_config].
    pub fn set_or_clear_scheduling_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::SchedulingConfig>,
    {
        self.scheduling_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [network_endpoints][crate::model::Node::network_endpoints].
    pub fn set_network_endpoints<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::NetworkEndpoint>,
    {
        use std::iter::Iterator;
        self.network_endpoints = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [health][crate::model::Node::health].
    pub fn set_health<T: std::convert::Into<crate::model::node::Health>>(mut self, v: T) -> Self {
        self.health = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::Node::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [metadata][crate::model::Node::metadata].
    pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [tags][crate::model::Node::tags].
    pub fn set_tags<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.tags = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [id][crate::model::Node::id].
    pub fn set_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [data_disks][crate::model::Node::data_disks].
    pub fn set_data_disks<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AttachedDisk>,
    {
        use std::iter::Iterator;
        self.data_disks = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [api_version][crate::model::Node::api_version].
    pub fn set_api_version<T: std::convert::Into<crate::model::node::ApiVersion>>(
        mut self,
        v: T,
    ) -> Self {
        self.api_version = v.into();
        self
    }

    /// Sets the value of [symptoms][crate::model::Node::symptoms].
    pub fn set_symptoms<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Symptom>,
    {
        use std::iter::Iterator;
        self.symptoms = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [shielded_instance_config][crate::model::Node::shielded_instance_config].
    pub fn set_shielded_instance_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ShieldedInstanceConfig>,
    {
        self.shielded_instance_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [shielded_instance_config][crate::model::Node::shielded_instance_config].
    pub fn set_or_clear_shielded_instance_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ShieldedInstanceConfig>,
    {
        self.shielded_instance_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [accelerator_config][crate::model::Node::accelerator_config].
    pub fn set_accelerator_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::AcceleratorConfig>,
    {
        self.accelerator_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [accelerator_config][crate::model::Node::accelerator_config].
    pub fn set_or_clear_accelerator_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::AcceleratorConfig>,
    {
        self.accelerator_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [queued_resource][crate::model::Node::queued_resource].
    pub fn set_queued_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.queued_resource = v.into();
        self
    }

    /// Sets the value of [multislice_node][crate::model::Node::multislice_node].
    pub fn set_multislice_node<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.multislice_node = v.into();
        self
    }
}

impl wkt::message::Message for Node {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.Node"
    }
}

/// Defines additional types related to [Node].
pub mod node {
    #[allow(unused_imports)]
    use super::*;

    /// Represents the different states of a TPU node during its lifecycle.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// TPU node state is not known/set.
        Unspecified,
        /// TPU node is being created.
        Creating,
        /// TPU node has been created.
        Ready,
        /// TPU node is restarting.
        Restarting,
        /// TPU node is undergoing reimaging.
        Reimaging,
        /// TPU node is being deleted.
        Deleting,
        /// TPU node is being repaired and may be unusable. Details can be
        /// found in the 'help_description' field.
        Repairing,
        /// TPU node is stopped.
        Stopped,
        /// TPU node is currently stopping.
        Stopping,
        /// TPU node is currently starting.
        Starting,
        /// TPU node has been preempted. Only applies to Preemptible TPU Nodes.
        Preempted,
        /// TPU node has been terminated due to maintenance or has reached the end of
        /// its life cycle (for preemptible nodes).
        Terminated,
        /// TPU node is currently hiding.
        Hiding,
        /// TPU node has been hidden.
        Hidden,
        /// TPU node is currently unhiding.
        Unhiding,
        /// TPU node has unknown state after a failed repair.
        Unknown,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Ready => std::option::Option::Some(2),
                Self::Restarting => std::option::Option::Some(3),
                Self::Reimaging => std::option::Option::Some(4),
                Self::Deleting => std::option::Option::Some(5),
                Self::Repairing => std::option::Option::Some(6),
                Self::Stopped => std::option::Option::Some(8),
                Self::Stopping => std::option::Option::Some(9),
                Self::Starting => std::option::Option::Some(10),
                Self::Preempted => std::option::Option::Some(11),
                Self::Terminated => std::option::Option::Some(12),
                Self::Hiding => std::option::Option::Some(13),
                Self::Hidden => std::option::Option::Some(14),
                Self::Unhiding => std::option::Option::Some(15),
                Self::Unknown => std::option::Option::Some(16),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Ready => std::option::Option::Some("READY"),
                Self::Restarting => std::option::Option::Some("RESTARTING"),
                Self::Reimaging => std::option::Option::Some("REIMAGING"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Repairing => std::option::Option::Some("REPAIRING"),
                Self::Stopped => std::option::Option::Some("STOPPED"),
                Self::Stopping => std::option::Option::Some("STOPPING"),
                Self::Starting => std::option::Option::Some("STARTING"),
                Self::Preempted => std::option::Option::Some("PREEMPTED"),
                Self::Terminated => std::option::Option::Some("TERMINATED"),
                Self::Hiding => std::option::Option::Some("HIDING"),
                Self::Hidden => std::option::Option::Some("HIDDEN"),
                Self::Unhiding => std::option::Option::Some("UNHIDING"),
                Self::Unknown => std::option::Option::Some("UNKNOWN"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Ready,
                3 => Self::Restarting,
                4 => Self::Reimaging,
                5 => Self::Deleting,
                6 => Self::Repairing,
                8 => Self::Stopped,
                9 => Self::Stopping,
                10 => Self::Starting,
                11 => Self::Preempted,
                12 => Self::Terminated,
                13 => Self::Hiding,
                14 => Self::Hidden,
                15 => Self::Unhiding,
                16 => Self::Unknown,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "READY" => Self::Ready,
                "RESTARTING" => Self::Restarting,
                "REIMAGING" => Self::Reimaging,
                "DELETING" => Self::Deleting,
                "REPAIRING" => Self::Repairing,
                "STOPPED" => Self::Stopped,
                "STOPPING" => Self::Stopping,
                "STARTING" => Self::Starting,
                "PREEMPTED" => Self::Preempted,
                "TERMINATED" => Self::Terminated,
                "HIDING" => Self::Hiding,
                "HIDDEN" => Self::Hidden,
                "UNHIDING" => Self::Unhiding,
                "UNKNOWN" => Self::Unknown,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Ready => serializer.serialize_i32(2),
                Self::Restarting => serializer.serialize_i32(3),
                Self::Reimaging => serializer.serialize_i32(4),
                Self::Deleting => serializer.serialize_i32(5),
                Self::Repairing => serializer.serialize_i32(6),
                Self::Stopped => serializer.serialize_i32(8),
                Self::Stopping => serializer.serialize_i32(9),
                Self::Starting => serializer.serialize_i32(10),
                Self::Preempted => serializer.serialize_i32(11),
                Self::Terminated => serializer.serialize_i32(12),
                Self::Hiding => serializer.serialize_i32(13),
                Self::Hidden => serializer.serialize_i32(14),
                Self::Unhiding => serializer.serialize_i32(15),
                Self::Unknown => serializer.serialize_i32(16),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.tpu.v2.Node.State",
            ))
        }
    }

    /// Health defines the status of a TPU node as reported by
    /// Health Monitor.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Health {
        /// Health status is unknown: not initialized or failed to retrieve.
        Unspecified,
        /// The resource is healthy.
        Healthy,
        /// The resource is unresponsive.
        Timeout,
        /// The in-guest ML stack is unhealthy.
        UnhealthyTensorflow,
        /// The node is under maintenance/priority boost caused rescheduling and
        /// will resume running once rescheduled.
        UnhealthyMaintenance,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Health::value] or
        /// [Health::name].
        UnknownValue(health::UnknownValue),
    }

    #[doc(hidden)]
    pub mod health {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Health {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Healthy => std::option::Option::Some(1),
                Self::Timeout => std::option::Option::Some(3),
                Self::UnhealthyTensorflow => std::option::Option::Some(4),
                Self::UnhealthyMaintenance => std::option::Option::Some(5),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("HEALTH_UNSPECIFIED"),
                Self::Healthy => std::option::Option::Some("HEALTHY"),
                Self::Timeout => std::option::Option::Some("TIMEOUT"),
                Self::UnhealthyTensorflow => std::option::Option::Some("UNHEALTHY_TENSORFLOW"),
                Self::UnhealthyMaintenance => std::option::Option::Some("UNHEALTHY_MAINTENANCE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Health {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Health {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Health {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Healthy,
                3 => Self::Timeout,
                4 => Self::UnhealthyTensorflow,
                5 => Self::UnhealthyMaintenance,
                _ => Self::UnknownValue(health::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Health {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "HEALTH_UNSPECIFIED" => Self::Unspecified,
                "HEALTHY" => Self::Healthy,
                "TIMEOUT" => Self::Timeout,
                "UNHEALTHY_TENSORFLOW" => Self::UnhealthyTensorflow,
                "UNHEALTHY_MAINTENANCE" => Self::UnhealthyMaintenance,
                _ => Self::UnknownValue(health::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Health {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Healthy => serializer.serialize_i32(1),
                Self::Timeout => serializer.serialize_i32(3),
                Self::UnhealthyTensorflow => serializer.serialize_i32(4),
                Self::UnhealthyMaintenance => serializer.serialize_i32(5),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Health {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Health>::new(
                ".google.cloud.tpu.v2.Node.Health",
            ))
        }
    }

    /// TPU API Version.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ApiVersion {
        /// API version is unknown.
        Unspecified,
        /// TPU API V1Alpha1 version.
        V1Alpha1,
        /// TPU API V1 version.
        V1,
        /// TPU API V2Alpha1 version.
        V2Alpha1,
        /// TPU API V2 version.
        V2,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [ApiVersion::value] or
        /// [ApiVersion::name].
        UnknownValue(api_version::UnknownValue),
    }

    #[doc(hidden)]
    pub mod api_version {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl ApiVersion {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::V1Alpha1 => std::option::Option::Some(1),
                Self::V1 => std::option::Option::Some(2),
                Self::V2Alpha1 => std::option::Option::Some(3),
                Self::V2 => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("API_VERSION_UNSPECIFIED"),
                Self::V1Alpha1 => std::option::Option::Some("V1_ALPHA1"),
                Self::V1 => std::option::Option::Some("V1"),
                Self::V2Alpha1 => std::option::Option::Some("V2_ALPHA1"),
                Self::V2 => std::option::Option::Some("V2"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for ApiVersion {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for ApiVersion {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for ApiVersion {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::V1Alpha1,
                2 => Self::V1,
                3 => Self::V2Alpha1,
                4 => Self::V2,
                _ => Self::UnknownValue(api_version::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for ApiVersion {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "API_VERSION_UNSPECIFIED" => Self::Unspecified,
                "V1_ALPHA1" => Self::V1Alpha1,
                "V1" => Self::V1,
                "V2_ALPHA1" => Self::V2Alpha1,
                "V2" => Self::V2,
                _ => Self::UnknownValue(api_version::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for ApiVersion {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::V1Alpha1 => serializer.serialize_i32(1),
                Self::V1 => serializer.serialize_i32(2),
                Self::V2Alpha1 => serializer.serialize_i32(3),
                Self::V2 => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for ApiVersion {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ApiVersion>::new(
                ".google.cloud.tpu.v2.Node.ApiVersion",
            ))
        }
    }
}

/// A QueuedResource represents a request for resources that will be placed
/// in a queue and fulfilled when the necessary resources are available.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct QueuedResource {
    /// Output only. Immutable. The name of the QueuedResource.
    pub name: std::string::String,

    /// Output only. The time when the QueuedResource was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Optional. The queueing policy of the QueuedRequest.
    pub queueing_policy: std::option::Option<crate::model::queued_resource::QueueingPolicy>,

    /// Output only. State of the QueuedResource request.
    pub state: std::option::Option<crate::model::QueuedResourceState>,

    /// Optional. Name of the reservation in which the resource should be
    /// provisioned. Format:
    /// projects/{project}/locations/{zone}/reservations/{reservation}
    pub reservation_name: std::string::String,

    /// Resource specification.
    pub resource: std::option::Option<crate::model::queued_resource::Resource>,

    /// Tier specifies the required tier.
    pub tier: std::option::Option<crate::model::queued_resource::Tier>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl QueuedResource {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::QueuedResource::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::QueuedResource::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::QueuedResource::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [queueing_policy][crate::model::QueuedResource::queueing_policy].
    pub fn set_queueing_policy<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::queued_resource::QueueingPolicy>,
    {
        self.queueing_policy = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [queueing_policy][crate::model::QueuedResource::queueing_policy].
    pub fn set_or_clear_queueing_policy<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::queued_resource::QueueingPolicy>,
    {
        self.queueing_policy = v.map(|x| x.into());
        self
    }

    /// Sets the value of [state][crate::model::QueuedResource::state].
    pub fn set_state<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::QueuedResourceState>,
    {
        self.state = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [state][crate::model::QueuedResource::state].
    pub fn set_or_clear_state<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::QueuedResourceState>,
    {
        self.state = v.map(|x| x.into());
        self
    }

    /// Sets the value of [reservation_name][crate::model::QueuedResource::reservation_name].
    pub fn set_reservation_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.reservation_name = v.into();
        self
    }

    /// Sets the value of [resource][crate::model::QueuedResource::resource].
    ///
    /// Note that all the setters affecting `resource` are mutually
    /// exclusive.
    pub fn set_resource<
        T: std::convert::Into<std::option::Option<crate::model::queued_resource::Resource>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.resource = v.into();
        self
    }

    /// The value of [resource][crate::model::QueuedResource::resource]
    /// if it holds a `Tpu`, `None` if the field is not set or
    /// holds a different branch.
    pub fn tpu(&self) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource::Tpu>> {
        #[allow(unreachable_patterns)]
        self.resource.as_ref().and_then(|v| match v {
            crate::model::queued_resource::Resource::Tpu(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [resource][crate::model::QueuedResource::resource]
    /// to hold a `Tpu`.
    ///
    /// Note that all the setters affecting `resource` are
    /// mutually exclusive.
    pub fn set_tpu<T: std::convert::Into<std::boxed::Box<crate::model::queued_resource::Tpu>>>(
        mut self,
        v: T,
    ) -> Self {
        self.resource =
            std::option::Option::Some(crate::model::queued_resource::Resource::Tpu(v.into()));
        self
    }

    /// Sets the value of [tier][crate::model::QueuedResource::tier].
    ///
    /// Note that all the setters affecting `tier` are mutually
    /// exclusive.
    pub fn set_tier<
        T: std::convert::Into<std::option::Option<crate::model::queued_resource::Tier>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.tier = v.into();
        self
    }

    /// The value of [tier][crate::model::QueuedResource::tier]
    /// if it holds a `Spot`, `None` if the field is not set or
    /// holds a different branch.
    pub fn spot(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource::Spot>> {
        #[allow(unreachable_patterns)]
        self.tier.as_ref().and_then(|v| match v {
            crate::model::queued_resource::Tier::Spot(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [tier][crate::model::QueuedResource::tier]
    /// to hold a `Spot`.
    ///
    /// Note that all the setters affecting `tier` are
    /// mutually exclusive.
    pub fn set_spot<T: std::convert::Into<std::boxed::Box<crate::model::queued_resource::Spot>>>(
        mut self,
        v: T,
    ) -> Self {
        self.tier = std::option::Option::Some(crate::model::queued_resource::Tier::Spot(v.into()));
        self
    }

    /// The value of [tier][crate::model::QueuedResource::tier]
    /// if it holds a `Guaranteed`, `None` if the field is not set or
    /// holds a different branch.
    pub fn guaranteed(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource::Guaranteed>> {
        #[allow(unreachable_patterns)]
        self.tier.as_ref().and_then(|v| match v {
            crate::model::queued_resource::Tier::Guaranteed(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [tier][crate::model::QueuedResource::tier]
    /// to hold a `Guaranteed`.
    ///
    /// Note that all the setters affecting `tier` are
    /// mutually exclusive.
    pub fn set_guaranteed<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource::Guaranteed>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.tier =
            std::option::Option::Some(crate::model::queued_resource::Tier::Guaranteed(v.into()));
        self
    }
}

impl wkt::message::Message for QueuedResource {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.QueuedResource"
    }
}

/// Defines additional types related to [QueuedResource].
pub mod queued_resource {
    #[allow(unused_imports)]
    use super::*;

    /// Details of the TPU resource(s) being requested.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Tpu {
        /// Optional. The TPU node(s) being requested.
        pub node_spec: std::vec::Vec<crate::model::queued_resource::tpu::NodeSpec>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Tpu {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [node_spec][crate::model::queued_resource::Tpu::node_spec].
        pub fn set_node_spec<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::queued_resource::tpu::NodeSpec>,
        {
            use std::iter::Iterator;
            self.node_spec = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for Tpu {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResource.Tpu"
        }
    }

    /// Defines additional types related to [Tpu].
    pub mod tpu {
        #[allow(unused_imports)]
        use super::*;

        /// Details of the TPU node(s) being requested. Users can request either a
        /// single node or multiple nodes.
        /// NodeSpec provides the specification for node(s) to be created.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct NodeSpec {
            /// Required. The parent resource name.
            pub parent: std::string::String,

            /// Required. The node.
            pub node: std::option::Option<crate::model::Node>,

            /// Either a node_id or multislice_params.
            pub name_strategy:
                std::option::Option<crate::model::queued_resource::tpu::node_spec::NameStrategy>,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl NodeSpec {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [parent][crate::model::queued_resource::tpu::NodeSpec::parent].
            pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
                self.parent = v.into();
                self
            }

            /// Sets the value of [node][crate::model::queued_resource::tpu::NodeSpec::node].
            pub fn set_node<T>(mut self, v: T) -> Self
            where
                T: std::convert::Into<crate::model::Node>,
            {
                self.node = std::option::Option::Some(v.into());
                self
            }

            /// Sets or clears the value of [node][crate::model::queued_resource::tpu::NodeSpec::node].
            pub fn set_or_clear_node<T>(mut self, v: std::option::Option<T>) -> Self
            where
                T: std::convert::Into<crate::model::Node>,
            {
                self.node = v.map(|x| x.into());
                self
            }

            /// Sets the value of [name_strategy][crate::model::queued_resource::tpu::NodeSpec::name_strategy].
            ///
            /// Note that all the setters affecting `name_strategy` are mutually
            /// exclusive.
            pub fn set_name_strategy<
                T: std::convert::Into<
                        std::option::Option<
                            crate::model::queued_resource::tpu::node_spec::NameStrategy,
                        >,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.name_strategy = v.into();
                self
            }

            /// The value of [name_strategy][crate::model::queued_resource::tpu::NodeSpec::name_strategy]
            /// if it holds a `NodeId`, `None` if the field is not set or
            /// holds a different branch.
            pub fn node_id(&self) -> std::option::Option<&std::string::String> {
                #[allow(unreachable_patterns)]
                self.name_strategy.as_ref().and_then(|v| match v {
                    crate::model::queued_resource::tpu::node_spec::NameStrategy::NodeId(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [name_strategy][crate::model::queued_resource::tpu::NodeSpec::name_strategy]
            /// to hold a `NodeId`.
            ///
            /// Note that all the setters affecting `name_strategy` are
            /// mutually exclusive.
            pub fn set_node_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
                self.name_strategy = std::option::Option::Some(
                    crate::model::queued_resource::tpu::node_spec::NameStrategy::NodeId(v.into()),
                );
                self
            }

            /// The value of [name_strategy][crate::model::queued_resource::tpu::NodeSpec::name_strategy]
            /// if it holds a `MultisliceParams`, `None` if the field is not set or
            /// holds a different branch.
            pub fn multislice_params(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::queued_resource::tpu::node_spec::MultisliceParams>,
            > {
                #[allow(unreachable_patterns)]
                self.name_strategy.as_ref().and_then(|v| match v {
                    crate::model::queued_resource::tpu::node_spec::NameStrategy::MultisliceParams(v) => std::option::Option::Some(v),
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [name_strategy][crate::model::queued_resource::tpu::NodeSpec::name_strategy]
            /// to hold a `MultisliceParams`.
            ///
            /// Note that all the setters affecting `name_strategy` are
            /// mutually exclusive.
            pub fn set_multislice_params<
                T: std::convert::Into<
                        std::boxed::Box<
                            crate::model::queued_resource::tpu::node_spec::MultisliceParams,
                        >,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.name_strategy = std::option::Option::Some(
                    crate::model::queued_resource::tpu::node_spec::NameStrategy::MultisliceParams(
                        v.into(),
                    ),
                );
                self
            }
        }

        impl wkt::message::Message for NodeSpec {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.tpu.v2.QueuedResource.Tpu.NodeSpec"
            }
        }

        /// Defines additional types related to [NodeSpec].
        pub mod node_spec {
            #[allow(unused_imports)]
            use super::*;

            /// Parameters to specify for multislice QueuedResource requests. This
            /// message must be populated in case of multislice requests instead of
            /// node_id.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct MultisliceParams {
                /// Required. Number of nodes with this spec. The system will attempt
                /// to provision "node_count" nodes as part of the request.
                /// This needs to be > 1.
                pub node_count: i32,

                /// Optional. Prefix of node_ids in case of multislice request.
                /// Should follow the `^[A-Za-z0-9_.~+%-]+$` regex format.
                /// If node_count = 3 and node_id_prefix = "np", node ids of nodes
                /// created will be "np-0", "np-1", "np-2". If this field is not
                /// provided we use queued_resource_id as the node_id_prefix.
                pub node_id_prefix: std::string::String,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl MultisliceParams {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [node_count][crate::model::queued_resource::tpu::node_spec::MultisliceParams::node_count].
                pub fn set_node_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
                    self.node_count = v.into();
                    self
                }

                /// Sets the value of [node_id_prefix][crate::model::queued_resource::tpu::node_spec::MultisliceParams::node_id_prefix].
                pub fn set_node_id_prefix<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.node_id_prefix = v.into();
                    self
                }
            }

            impl wkt::message::Message for MultisliceParams {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.tpu.v2.QueuedResource.Tpu.NodeSpec.MultisliceParams"
                }
            }

            /// Either a node_id or multislice_params.
            #[derive(Clone, Debug, PartialEq)]
            #[non_exhaustive]
            pub enum NameStrategy {
                /// Optional. The unqualified resource name. Should follow the
                /// `^[A-Za-z0-9_.~+%-]+$` regex format. This is only specified when
                /// requesting a single node. In case of multislice requests,
                /// multislice_params must be populated instead.
                NodeId(std::string::String),
                /// Optional. Fields to specify in case of multislice request.
                MultisliceParams(
                    std::boxed::Box<
                        crate::model::queued_resource::tpu::node_spec::MultisliceParams,
                    >,
                ),
            }
        }
    }

    /// Spot tier definition.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Spot {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Spot {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for Spot {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResource.Spot"
        }
    }

    /// Guaranteed tier definition.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Guaranteed {
        /// Optional. Defines the minimum duration of the guarantee. If specified,
        /// the requested resources will only be provisioned if they can be
        /// allocated for at least the given duration.
        pub min_duration: std::option::Option<wkt::Duration>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Guaranteed {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [min_duration][crate::model::queued_resource::Guaranteed::min_duration].
        pub fn set_min_duration<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.min_duration = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [min_duration][crate::model::queued_resource::Guaranteed::min_duration].
        pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.min_duration = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for Guaranteed {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResource.Guaranteed"
        }
    }

    /// Defines the policy of the QueuedRequest.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct QueueingPolicy {
        /// Time flexibility specification.
        pub start_timing_constraints: std::option::Option<
            crate::model::queued_resource::queueing_policy::StartTimingConstraints,
        >,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl QueueingPolicy {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints].
        ///
        /// Note that all the setters affecting `start_timing_constraints` are mutually
        /// exclusive.
        pub fn set_start_timing_constraints<
            T: std::convert::Into<
                    std::option::Option<
                        crate::model::queued_resource::queueing_policy::StartTimingConstraints,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.start_timing_constraints = v.into();
            self
        }

        /// The value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// if it holds a `ValidUntilDuration`, `None` if the field is not set or
        /// holds a different branch.
        pub fn valid_until_duration(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
            #[allow(unreachable_patterns)]
            self.start_timing_constraints.as_ref().and_then(|v| match v {
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidUntilDuration(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// to hold a `ValidUntilDuration`.
        ///
        /// Note that all the setters affecting `start_timing_constraints` are
        /// mutually exclusive.
        pub fn set_valid_until_duration<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
            mut self,
            v: T,
        ) -> Self {
            self.start_timing_constraints = std::option::Option::Some(
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidUntilDuration(
                    v.into()
                )
            );
            self
        }

        /// The value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// if it holds a `ValidUntilTime`, `None` if the field is not set or
        /// holds a different branch.
        pub fn valid_until_time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
            #[allow(unreachable_patterns)]
            self.start_timing_constraints.as_ref().and_then(|v| match v {
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidUntilTime(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// to hold a `ValidUntilTime`.
        ///
        /// Note that all the setters affecting `start_timing_constraints` are
        /// mutually exclusive.
        pub fn set_valid_until_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
            mut self,
            v: T,
        ) -> Self {
            self.start_timing_constraints = std::option::Option::Some(
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidUntilTime(
                    v.into()
                )
            );
            self
        }

        /// The value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// if it holds a `ValidAfterDuration`, `None` if the field is not set or
        /// holds a different branch.
        pub fn valid_after_duration(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
            #[allow(unreachable_patterns)]
            self.start_timing_constraints.as_ref().and_then(|v| match v {
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidAfterDuration(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// to hold a `ValidAfterDuration`.
        ///
        /// Note that all the setters affecting `start_timing_constraints` are
        /// mutually exclusive.
        pub fn set_valid_after_duration<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
            mut self,
            v: T,
        ) -> Self {
            self.start_timing_constraints = std::option::Option::Some(
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidAfterDuration(
                    v.into()
                )
            );
            self
        }

        /// The value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// if it holds a `ValidAfterTime`, `None` if the field is not set or
        /// holds a different branch.
        pub fn valid_after_time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
            #[allow(unreachable_patterns)]
            self.start_timing_constraints.as_ref().and_then(|v| match v {
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidAfterTime(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// to hold a `ValidAfterTime`.
        ///
        /// Note that all the setters affecting `start_timing_constraints` are
        /// mutually exclusive.
        pub fn set_valid_after_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
            mut self,
            v: T,
        ) -> Self {
            self.start_timing_constraints = std::option::Option::Some(
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidAfterTime(
                    v.into()
                )
            );
            self
        }

        /// The value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// if it holds a `ValidInterval`, `None` if the field is not set or
        /// holds a different branch.
        pub fn valid_interval(
            &self,
        ) -> std::option::Option<&std::boxed::Box<gtype::model::Interval>> {
            #[allow(unreachable_patterns)]
            self.start_timing_constraints.as_ref().and_then(|v| match v {
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidInterval(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [start_timing_constraints][crate::model::queued_resource::QueueingPolicy::start_timing_constraints]
        /// to hold a `ValidInterval`.
        ///
        /// Note that all the setters affecting `start_timing_constraints` are
        /// mutually exclusive.
        pub fn set_valid_interval<
            T: std::convert::Into<std::boxed::Box<gtype::model::Interval>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.start_timing_constraints = std::option::Option::Some(
                crate::model::queued_resource::queueing_policy::StartTimingConstraints::ValidInterval(
                    v.into()
                )
            );
            self
        }
    }

    impl wkt::message::Message for QueueingPolicy {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResource.QueueingPolicy"
        }
    }

    /// Defines additional types related to [QueueingPolicy].
    pub mod queueing_policy {
        #[allow(unused_imports)]
        use super::*;

        /// Time flexibility specification.
        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum StartTimingConstraints {
            /// Optional. A relative time after which resources should not be created.
            /// If the request cannot be fulfilled by this time the request will be
            /// failed.
            ValidUntilDuration(std::boxed::Box<wkt::Duration>),
            /// Optional. An absolute time after which resources should not be created.
            /// If the request cannot be fulfilled by this time the request will be
            /// failed.
            ValidUntilTime(std::boxed::Box<wkt::Timestamp>),
            /// Optional. A relative time after which resources may be created.
            ValidAfterDuration(std::boxed::Box<wkt::Duration>),
            /// Optional. An absolute time after which resources may be created.
            ValidAfterTime(std::boxed::Box<wkt::Timestamp>),
            /// Optional. An absolute time interval within which resources may be
            /// created.
            ValidInterval(std::boxed::Box<gtype::model::Interval>),
        }
    }

    /// Resource specification.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Resource {
        /// Optional. Defines a TPU resource.
        Tpu(std::boxed::Box<crate::model::queued_resource::Tpu>),
    }

    /// Tier specifies the required tier.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Tier {
        /// Optional. The Spot tier.
        Spot(std::boxed::Box<crate::model::queued_resource::Spot>),
        /// Optional. The Guaranteed tier
        Guaranteed(std::boxed::Box<crate::model::queued_resource::Guaranteed>),
    }
}

/// QueuedResourceState defines the details of the QueuedResource request.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct QueuedResourceState {
    /// Output only. State of the QueuedResource request.
    pub state: crate::model::queued_resource_state::State,

    /// Output only. The initiator of the QueuedResources's current state. Used to
    /// indicate whether the SUSPENDING/SUSPENDED state was initiated by the user
    /// or the service.
    pub state_initiator: crate::model::queued_resource_state::StateInitiator,

    /// Further data for the state.
    pub state_data: std::option::Option<crate::model::queued_resource_state::StateData>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl QueuedResourceState {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [state][crate::model::QueuedResourceState::state].
    pub fn set_state<T: std::convert::Into<crate::model::queued_resource_state::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [state_initiator][crate::model::QueuedResourceState::state_initiator].
    pub fn set_state_initiator<
        T: std::convert::Into<crate::model::queued_resource_state::StateInitiator>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_initiator = v.into();
        self
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data].
    ///
    /// Note that all the setters affecting `state_data` are mutually
    /// exclusive.
    pub fn set_state_data<
        T: std::convert::Into<std::option::Option<crate::model::queued_resource_state::StateData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = v.into();
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `CreatingData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn creating_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::CreatingData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::CreatingData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `CreatingData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_creating_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::CreatingData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::CreatingData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `AcceptedData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn accepted_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::AcceptedData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::AcceptedData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `AcceptedData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_accepted_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::AcceptedData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::AcceptedData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `ProvisioningData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn provisioning_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::ProvisioningData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::ProvisioningData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `ProvisioningData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_provisioning_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::ProvisioningData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::ProvisioningData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `FailedData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn failed_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::FailedData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::FailedData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `FailedData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_failed_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::FailedData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::FailedData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `DeletingData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn deleting_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::DeletingData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::DeletingData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `DeletingData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_deleting_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::DeletingData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::DeletingData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `ActiveData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn active_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::ActiveData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::ActiveData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `ActiveData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_active_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::ActiveData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::ActiveData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `SuspendingData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn suspending_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::SuspendingData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::SuspendingData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `SuspendingData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_suspending_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::SuspendingData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::SuspendingData(v.into()),
        );
        self
    }

    /// The value of [state_data][crate::model::QueuedResourceState::state_data]
    /// if it holds a `SuspendedData`, `None` if the field is not set or
    /// holds a different branch.
    pub fn suspended_data(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::queued_resource_state::SuspendedData>>
    {
        #[allow(unreachable_patterns)]
        self.state_data.as_ref().and_then(|v| match v {
            crate::model::queued_resource_state::StateData::SuspendedData(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [state_data][crate::model::QueuedResourceState::state_data]
    /// to hold a `SuspendedData`.
    ///
    /// Note that all the setters affecting `state_data` are
    /// mutually exclusive.
    pub fn set_suspended_data<
        T: std::convert::Into<std::boxed::Box<crate::model::queued_resource_state::SuspendedData>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.state_data = std::option::Option::Some(
            crate::model::queued_resource_state::StateData::SuspendedData(v.into()),
        );
        self
    }
}

impl wkt::message::Message for QueuedResourceState {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState"
    }
}

/// Defines additional types related to [QueuedResourceState].
pub mod queued_resource_state {
    #[allow(unused_imports)]
    use super::*;

    /// Further data for the creating state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct CreatingData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl CreatingData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for CreatingData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.CreatingData"
        }
    }

    /// Further data for the accepted state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct AcceptedData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl AcceptedData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for AcceptedData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.AcceptedData"
        }
    }

    /// Further data for the provisioning state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ProvisioningData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ProvisioningData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for ProvisioningData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.ProvisioningData"
        }
    }

    /// Further data for the failed state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct FailedData {
        /// Output only. The error that caused the queued resource to enter the
        /// FAILED state.
        pub error: std::option::Option<rpc::model::Status>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl FailedData {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [error][crate::model::queued_resource_state::FailedData::error].
        pub fn set_error<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<rpc::model::Status>,
        {
            self.error = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [error][crate::model::queued_resource_state::FailedData::error].
        pub fn set_or_clear_error<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<rpc::model::Status>,
        {
            self.error = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for FailedData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.FailedData"
        }
    }

    /// Further data for the deleting state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct DeletingData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl DeletingData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for DeletingData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.DeletingData"
        }
    }

    /// Further data for the active state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ActiveData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ActiveData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for ActiveData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.ActiveData"
        }
    }

    /// Further data for the suspending state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct SuspendingData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl SuspendingData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for SuspendingData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.SuspendingData"
        }
    }

    /// Further data for the suspended state.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct SuspendedData {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl SuspendedData {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for SuspendedData {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.tpu.v2.QueuedResourceState.SuspendedData"
        }
    }

    /// Output only state of the request
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// State of the QueuedResource request is not known/set.
        Unspecified,
        /// The QueuedResource request has been received. We're still working on
        /// determining if we will be able to honor this request.
        Creating,
        /// The QueuedResource request has passed initial validation/admission
        /// control and has been persisted in the queue.
        Accepted,
        /// The QueuedResource request has been selected. The
        /// associated resources are currently being provisioned (or very soon
        /// will begin provisioning).
        Provisioning,
        /// The request could not be completed. This may be due to some
        /// late-discovered problem with the request itself, or due to
        /// unavailability of resources within the constraints of the request
        /// (e.g., the 'valid until' start timing constraint expired).
        Failed,
        /// The QueuedResource is being deleted.
        Deleting,
        /// The resources specified in the QueuedResource request have been
        /// provisioned and are ready for use by the end-user/consumer.
        Active,
        /// The resources specified in the QueuedResource request are being
        /// deleted. This may have been initiated by the user, or
        /// the Cloud TPU service. Inspect the state data for more details.
        Suspending,
        /// The resources specified in the QueuedResource request have been
        /// deleted.
        Suspended,
        /// The QueuedResource request has passed initial validation and has been
        /// persisted in the queue. It will remain in this state until there are
        /// sufficient free resources to begin provisioning your request. Wait times
        /// will vary significantly depending on demand levels. When demand is high,
        /// not all requests can be immediately provisioned. If you
        /// need more reliable obtainability of TPUs consider purchasing a
        /// reservation. To put a limit on how long you are willing to wait, use
        /// [timing
        /// constraints](https://cloud.google.com/tpu/docs/queued-resources#request_a_queued_resource_before_a_specified_time).
        WaitingForResources,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Accepted => std::option::Option::Some(2),
                Self::Provisioning => std::option::Option::Some(3),
                Self::Failed => std::option::Option::Some(4),
                Self::Deleting => std::option::Option::Some(5),
                Self::Active => std::option::Option::Some(6),
                Self::Suspending => std::option::Option::Some(7),
                Self::Suspended => std::option::Option::Some(8),
                Self::WaitingForResources => std::option::Option::Some(9),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Accepted => std::option::Option::Some("ACCEPTED"),
                Self::Provisioning => std::option::Option::Some("PROVISIONING"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::Suspending => std::option::Option::Some("SUSPENDING"),
                Self::Suspended => std::option::Option::Some("SUSPENDED"),
                Self::WaitingForResources => std::option::Option::Some("WAITING_FOR_RESOURCES"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Accepted,
                3 => Self::Provisioning,
                4 => Self::Failed,
                5 => Self::Deleting,
                6 => Self::Active,
                7 => Self::Suspending,
                8 => Self::Suspended,
                9 => Self::WaitingForResources,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "ACCEPTED" => Self::Accepted,
                "PROVISIONING" => Self::Provisioning,
                "FAILED" => Self::Failed,
                "DELETING" => Self::Deleting,
                "ACTIVE" => Self::Active,
                "SUSPENDING" => Self::Suspending,
                "SUSPENDED" => Self::Suspended,
                "WAITING_FOR_RESOURCES" => Self::WaitingForResources,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Accepted => serializer.serialize_i32(2),
                Self::Provisioning => serializer.serialize_i32(3),
                Self::Failed => serializer.serialize_i32(4),
                Self::Deleting => serializer.serialize_i32(5),
                Self::Active => serializer.serialize_i32(6),
                Self::Suspending => serializer.serialize_i32(7),
                Self::Suspended => serializer.serialize_i32(8),
                Self::WaitingForResources => serializer.serialize_i32(9),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.tpu.v2.QueuedResourceState.State",
            ))
        }
    }

    /// The initiator of the QueuedResource's SUSPENDING/SUSPENDED state.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum StateInitiator {
        /// The state initiator is unspecified.
        Unspecified,
        /// The current QueuedResource state was initiated by the user.
        User,
        /// The current QueuedResource state was initiated by the service.
        Service,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [StateInitiator::value] or
        /// [StateInitiator::name].
        UnknownValue(state_initiator::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state_initiator {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl StateInitiator {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::User => std::option::Option::Some(1),
                Self::Service => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_INITIATOR_UNSPECIFIED"),
                Self::User => std::option::Option::Some("USER"),
                Self::Service => std::option::Option::Some("SERVICE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for StateInitiator {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for StateInitiator {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for StateInitiator {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::User,
                2 => Self::Service,
                _ => Self::UnknownValue(state_initiator::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for StateInitiator {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_INITIATOR_UNSPECIFIED" => Self::Unspecified,
                "USER" => Self::User,
                "SERVICE" => Self::Service,
                _ => Self::UnknownValue(state_initiator::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for StateInitiator {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::User => serializer.serialize_i32(1),
                Self::Service => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for StateInitiator {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<StateInitiator>::new(
                ".google.cloud.tpu.v2.QueuedResourceState.StateInitiator",
            ))
        }
    }

    /// Further data for the state.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum StateData {
        /// Output only. Further data for the creating state.
        CreatingData(std::boxed::Box<crate::model::queued_resource_state::CreatingData>),
        /// Output only. Further data for the accepted state.
        AcceptedData(std::boxed::Box<crate::model::queued_resource_state::AcceptedData>),
        /// Output only. Further data for the provisioning state.
        ProvisioningData(std::boxed::Box<crate::model::queued_resource_state::ProvisioningData>),
        /// Output only. Further data for the failed state.
        FailedData(std::boxed::Box<crate::model::queued_resource_state::FailedData>),
        /// Output only. Further data for the deleting state.
        DeletingData(std::boxed::Box<crate::model::queued_resource_state::DeletingData>),
        /// Output only. Further data for the active state.
        ActiveData(std::boxed::Box<crate::model::queued_resource_state::ActiveData>),
        /// Output only. Further data for the suspending state.
        SuspendingData(std::boxed::Box<crate::model::queued_resource_state::SuspendingData>),
        /// Output only. Further data for the suspended state.
        SuspendedData(std::boxed::Box<crate::model::queued_resource_state::SuspendedData>),
    }
}

/// Request for [ListNodes][google.cloud.tpu.v2.Tpu.ListNodes].
///
/// [google.cloud.tpu.v2.Tpu.ListNodes]: crate::client::Tpu::list_nodes
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListNodesRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    /// The maximum number of items to return.
    pub page_size: i32,

    /// The next_page_token value returned from a previous List request, if any.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListNodesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListNodesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListNodesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListNodesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListNodesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListNodesRequest"
    }
}

/// Response for [ListNodes][google.cloud.tpu.v2.Tpu.ListNodes].
///
/// [google.cloud.tpu.v2.Tpu.ListNodes]: crate::client::Tpu::list_nodes
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListNodesResponse {
    /// The listed nodes.
    pub nodes: std::vec::Vec<crate::model::Node>,

    /// The next page token or empty if none.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListNodesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [nodes][crate::model::ListNodesResponse::nodes].
    pub fn set_nodes<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Node>,
    {
        use std::iter::Iterator;
        self.nodes = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListNodesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListNodesResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListNodesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListNodesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListNodesResponse {
    type PageItem = crate::model::Node;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.nodes
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request for [GetNode][google.cloud.tpu.v2.Tpu.GetNode].
///
/// [google.cloud.tpu.v2.Tpu.GetNode]: crate::client::Tpu::get_node
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetNodeRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetNodeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetNodeRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetNodeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GetNodeRequest"
    }
}

/// Request for [CreateNode][google.cloud.tpu.v2.Tpu.CreateNode].
///
/// [google.cloud.tpu.v2.Tpu.CreateNode]: crate::client::Tpu::create_node
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateNodeRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    /// The unqualified resource name.
    pub node_id: std::string::String,

    /// Required. The node.
    pub node: std::option::Option<crate::model::Node>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateNodeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateNodeRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [node_id][crate::model::CreateNodeRequest::node_id].
    pub fn set_node_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.node_id = v.into();
        self
    }

    /// Sets the value of [node][crate::model::CreateNodeRequest::node].
    pub fn set_node<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Node>,
    {
        self.node = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [node][crate::model::CreateNodeRequest::node].
    pub fn set_or_clear_node<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Node>,
    {
        self.node = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateNodeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.CreateNodeRequest"
    }
}

/// Request for [DeleteNode][google.cloud.tpu.v2.Tpu.DeleteNode].
///
/// [google.cloud.tpu.v2.Tpu.DeleteNode]: crate::client::Tpu::delete_node
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteNodeRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteNodeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteNodeRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteNodeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.DeleteNodeRequest"
    }
}

/// Request for [StopNode][google.cloud.tpu.v2.Tpu.StopNode].
///
/// [google.cloud.tpu.v2.Tpu.StopNode]: crate::client::Tpu::stop_node
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct StopNodeRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl StopNodeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::StopNodeRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for StopNodeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.StopNodeRequest"
    }
}

/// Request for [StartNode][google.cloud.tpu.v2.Tpu.StartNode].
///
/// [google.cloud.tpu.v2.Tpu.StartNode]: crate::client::Tpu::start_node
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct StartNodeRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl StartNodeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::StartNodeRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for StartNodeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.StartNodeRequest"
    }
}

/// Request for [UpdateNode][google.cloud.tpu.v2.Tpu.UpdateNode].
///
/// [google.cloud.tpu.v2.Tpu.UpdateNode]: crate::client::Tpu::update_node
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateNodeRequest {
    /// Required. Mask of fields from [Node][Tpu.Node] to update.
    /// Supported fields: [description, tags, labels, metadata,
    /// network_config.enable_external_ips].
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. The node. Only fields specified in update_mask are updated.
    pub node: std::option::Option<crate::model::Node>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateNodeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdateNodeRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateNodeRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [node][crate::model::UpdateNodeRequest::node].
    pub fn set_node<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Node>,
    {
        self.node = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [node][crate::model::UpdateNodeRequest::node].
    pub fn set_or_clear_node<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Node>,
    {
        self.node = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateNodeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.UpdateNodeRequest"
    }
}

/// Request for
/// [ListQueuedResources][google.cloud.tpu.v2.Tpu.ListQueuedResources].
///
/// [google.cloud.tpu.v2.Tpu.ListQueuedResources]: crate::client::Tpu::list_queued_resources
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListQueuedResourcesRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    /// Optional. The maximum number of items to return.
    pub page_size: i32,

    /// Optional. The next_page_token value returned from a previous List request,
    /// if any.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListQueuedResourcesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListQueuedResourcesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListQueuedResourcesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListQueuedResourcesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListQueuedResourcesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListQueuedResourcesRequest"
    }
}

/// Response for
/// [ListQueuedResources][google.cloud.tpu.v2.Tpu.ListQueuedResources].
///
/// [google.cloud.tpu.v2.Tpu.ListQueuedResources]: crate::client::Tpu::list_queued_resources
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListQueuedResourcesResponse {
    /// The listed queued resources.
    pub queued_resources: std::vec::Vec<crate::model::QueuedResource>,

    /// The next page token or empty if none.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListQueuedResourcesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [queued_resources][crate::model::ListQueuedResourcesResponse::queued_resources].
    pub fn set_queued_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::QueuedResource>,
    {
        use std::iter::Iterator;
        self.queued_resources = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListQueuedResourcesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListQueuedResourcesResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListQueuedResourcesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListQueuedResourcesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListQueuedResourcesResponse {
    type PageItem = crate::model::QueuedResource;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.queued_resources
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request for [GetQueuedResource][google.cloud.tpu.v2.Tpu.GetQueuedResource]
///
/// [google.cloud.tpu.v2.Tpu.GetQueuedResource]: crate::client::Tpu::get_queued_resource
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetQueuedResourceRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetQueuedResourceRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetQueuedResourceRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetQueuedResourceRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GetQueuedResourceRequest"
    }
}

/// Request for
/// [CreateQueuedResource][google.cloud.tpu.v2.Tpu.CreateQueuedResource].
///
/// [google.cloud.tpu.v2.Tpu.CreateQueuedResource]: crate::client::Tpu::create_queued_resource
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateQueuedResourceRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    /// Optional. The unqualified resource name. Should follow the
    /// `^[A-Za-z0-9_.~+%-]+$` regex format.
    pub queued_resource_id: std::string::String,

    /// Required. The queued resource.
    pub queued_resource: std::option::Option<crate::model::QueuedResource>,

    /// Optional. Idempotent request UUID.
    pub request_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateQueuedResourceRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateQueuedResourceRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [queued_resource_id][crate::model::CreateQueuedResourceRequest::queued_resource_id].
    pub fn set_queued_resource_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.queued_resource_id = v.into();
        self
    }

    /// Sets the value of [queued_resource][crate::model::CreateQueuedResourceRequest::queued_resource].
    pub fn set_queued_resource<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::QueuedResource>,
    {
        self.queued_resource = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [queued_resource][crate::model::CreateQueuedResourceRequest::queued_resource].
    pub fn set_or_clear_queued_resource<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::QueuedResource>,
    {
        self.queued_resource = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::CreateQueuedResourceRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }
}

impl wkt::message::Message for CreateQueuedResourceRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.CreateQueuedResourceRequest"
    }
}

/// Request for
/// [DeleteQueuedResource][google.cloud.tpu.v2.Tpu.DeleteQueuedResource].
///
/// [google.cloud.tpu.v2.Tpu.DeleteQueuedResource]: crate::client::Tpu::delete_queued_resource
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteQueuedResourceRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    /// Optional. Idempotent request UUID.
    pub request_id: std::string::String,

    /// Optional. If set to true, all running nodes belonging to this queued
    /// resource will be deleted first and then the queued resource will be
    /// deleted. Otherwise (i.e. force=false), the queued resource will only be
    /// deleted if its nodes have already been deleted or the queued resource is in
    /// the ACCEPTED, FAILED, or SUSPENDED state.
    pub force: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteQueuedResourceRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteQueuedResourceRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [request_id][crate::model::DeleteQueuedResourceRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }

    /// Sets the value of [force][crate::model::DeleteQueuedResourceRequest::force].
    pub fn set_force<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.force = v.into();
        self
    }
}

impl wkt::message::Message for DeleteQueuedResourceRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.DeleteQueuedResourceRequest"
    }
}

/// Request for
/// [ResetQueuedResource][google.cloud.tpu.v2.Tpu.ResetQueuedResource].
///
/// [google.cloud.tpu.v2.Tpu.ResetQueuedResource]: crate::client::Tpu::reset_queued_resource
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResetQueuedResourceRequest {
    /// Required. The name of the queued resource.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResetQueuedResourceRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ResetQueuedResourceRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for ResetQueuedResourceRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ResetQueuedResourceRequest"
    }
}

/// The per-product per-project service identity for Cloud TPU service.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ServiceIdentity {
    /// The email address of the service identity.
    pub email: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ServiceIdentity {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [email][crate::model::ServiceIdentity::email].
    pub fn set_email<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.email = v.into();
        self
    }
}

impl wkt::message::Message for ServiceIdentity {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ServiceIdentity"
    }
}

/// Request for
/// [GenerateServiceIdentity][google.cloud.tpu.v2.Tpu.GenerateServiceIdentity].
///
/// [google.cloud.tpu.v2.Tpu.GenerateServiceIdentity]: crate::client::Tpu::generate_service_identity
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GenerateServiceIdentityRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GenerateServiceIdentityRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::GenerateServiceIdentityRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }
}

impl wkt::message::Message for GenerateServiceIdentityRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GenerateServiceIdentityRequest"
    }
}

/// Response for
/// [GenerateServiceIdentity][google.cloud.tpu.v2.Tpu.GenerateServiceIdentity].
///
/// [google.cloud.tpu.v2.Tpu.GenerateServiceIdentity]: crate::client::Tpu::generate_service_identity
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GenerateServiceIdentityResponse {
    /// ServiceIdentity that was created or retrieved.
    pub identity: std::option::Option<crate::model::ServiceIdentity>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GenerateServiceIdentityResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [identity][crate::model::GenerateServiceIdentityResponse::identity].
    pub fn set_identity<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ServiceIdentity>,
    {
        self.identity = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [identity][crate::model::GenerateServiceIdentityResponse::identity].
    pub fn set_or_clear_identity<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ServiceIdentity>,
    {
        self.identity = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for GenerateServiceIdentityResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GenerateServiceIdentityResponse"
    }
}

/// A accelerator type that a Node can be configured with.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AcceleratorType {
    /// The resource name.
    pub name: std::string::String,

    /// The accelerator type.
    pub r#type: std::string::String,

    /// The accelerator config.
    pub accelerator_configs: std::vec::Vec<crate::model::AcceleratorConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AcceleratorType {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::AcceleratorType::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::AcceleratorType::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [accelerator_configs][crate::model::AcceleratorType::accelerator_configs].
    pub fn set_accelerator_configs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AcceleratorConfig>,
    {
        use std::iter::Iterator;
        self.accelerator_configs = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for AcceleratorType {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.AcceleratorType"
    }
}

/// Request for [GetAcceleratorType][google.cloud.tpu.v2.Tpu.GetAcceleratorType].
///
/// [google.cloud.tpu.v2.Tpu.GetAcceleratorType]: crate::client::Tpu::get_accelerator_type
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetAcceleratorTypeRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetAcceleratorTypeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetAcceleratorTypeRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetAcceleratorTypeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GetAcceleratorTypeRequest"
    }
}

/// Request for
/// [ListAcceleratorTypes][google.cloud.tpu.v2.Tpu.ListAcceleratorTypes].
///
/// [google.cloud.tpu.v2.Tpu.ListAcceleratorTypes]: crate::client::Tpu::list_accelerator_types
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListAcceleratorTypesRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    /// The maximum number of items to return.
    pub page_size: i32,

    /// The next_page_token value returned from a previous List request, if any.
    pub page_token: std::string::String,

    /// List filter.
    pub filter: std::string::String,

    /// Sort results.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListAcceleratorTypesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListAcceleratorTypesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListAcceleratorTypesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListAcceleratorTypesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListAcceleratorTypesRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListAcceleratorTypesRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListAcceleratorTypesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListAcceleratorTypesRequest"
    }
}

/// Response for
/// [ListAcceleratorTypes][google.cloud.tpu.v2.Tpu.ListAcceleratorTypes].
///
/// [google.cloud.tpu.v2.Tpu.ListAcceleratorTypes]: crate::client::Tpu::list_accelerator_types
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListAcceleratorTypesResponse {
    /// The listed nodes.
    pub accelerator_types: std::vec::Vec<crate::model::AcceleratorType>,

    /// The next page token or empty if none.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListAcceleratorTypesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [accelerator_types][crate::model::ListAcceleratorTypesResponse::accelerator_types].
    pub fn set_accelerator_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AcceleratorType>,
    {
        use std::iter::Iterator;
        self.accelerator_types = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListAcceleratorTypesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListAcceleratorTypesResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListAcceleratorTypesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListAcceleratorTypesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListAcceleratorTypesResponse {
    type PageItem = crate::model::AcceleratorType;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.accelerator_types
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// A runtime version that a Node can be configured with.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RuntimeVersion {
    /// The resource name.
    pub name: std::string::String,

    /// The runtime version.
    pub version: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RuntimeVersion {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::RuntimeVersion::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [version][crate::model::RuntimeVersion::version].
    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.version = v.into();
        self
    }
}

impl wkt::message::Message for RuntimeVersion {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.RuntimeVersion"
    }
}

/// Request for [GetRuntimeVersion][google.cloud.tpu.v2.Tpu.GetRuntimeVersion].
///
/// [google.cloud.tpu.v2.Tpu.GetRuntimeVersion]: crate::client::Tpu::get_runtime_version
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetRuntimeVersionRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetRuntimeVersionRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetRuntimeVersionRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetRuntimeVersionRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GetRuntimeVersionRequest"
    }
}

/// Request for
/// [ListRuntimeVersions][google.cloud.tpu.v2.Tpu.ListRuntimeVersions].
///
/// [google.cloud.tpu.v2.Tpu.ListRuntimeVersions]: crate::client::Tpu::list_runtime_versions
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListRuntimeVersionsRequest {
    /// Required. The parent resource name.
    pub parent: std::string::String,

    /// The maximum number of items to return.
    pub page_size: i32,

    /// The next_page_token value returned from a previous List request, if any.
    pub page_token: std::string::String,

    /// List filter.
    pub filter: std::string::String,

    /// Sort results.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListRuntimeVersionsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListRuntimeVersionsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListRuntimeVersionsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListRuntimeVersionsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListRuntimeVersionsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListRuntimeVersionsRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListRuntimeVersionsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListRuntimeVersionsRequest"
    }
}

/// Response for
/// [ListRuntimeVersions][google.cloud.tpu.v2.Tpu.ListRuntimeVersions].
///
/// [google.cloud.tpu.v2.Tpu.ListRuntimeVersions]: crate::client::Tpu::list_runtime_versions
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListRuntimeVersionsResponse {
    /// The listed nodes.
    pub runtime_versions: std::vec::Vec<crate::model::RuntimeVersion>,

    /// The next page token or empty if none.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListRuntimeVersionsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [runtime_versions][crate::model::ListRuntimeVersionsResponse::runtime_versions].
    pub fn set_runtime_versions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::RuntimeVersion>,
    {
        use std::iter::Iterator;
        self.runtime_versions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListRuntimeVersionsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListRuntimeVersionsResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListRuntimeVersionsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ListRuntimeVersionsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListRuntimeVersionsResponse {
    type PageItem = crate::model::RuntimeVersion;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.runtime_versions
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Metadata describing an [Operation][google.longrunning.Operation]
///
/// [google.longrunning.Operation]: longrunning::model::Operation
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Target of the operation - for example
    /// projects/project-1/connectivityTests/test-1
    pub target: std::string::String,

    /// Name of the verb executed by the operation.
    pub verb: std::string::String,

    /// Human-readable status of the operation, if any.
    pub status_detail: std::string::String,

    /// Specifies if cancellation was requested for the operation.
    pub cancel_requested: bool,

    /// API version.
    pub api_version: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::OperationMetadata::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.verb = v.into();
        self
    }

    /// Sets the value of [status_detail][crate::model::OperationMetadata::status_detail].
    pub fn set_status_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.status_detail = v.into();
        self
    }

    /// Sets the value of [cancel_requested][crate::model::OperationMetadata::cancel_requested].
    pub fn set_cancel_requested<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.cancel_requested = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.OperationMetadata"
    }
}

/// A Symptom instance.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Symptom {
    /// Timestamp when the Symptom is created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Type of the Symptom.
    pub symptom_type: crate::model::symptom::SymptomType,

    /// Detailed information of the current Symptom.
    pub details: std::string::String,

    /// A string used to uniquely distinguish a worker within a TPU node.
    pub worker_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Symptom {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::Symptom::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Symptom::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [symptom_type][crate::model::Symptom::symptom_type].
    pub fn set_symptom_type<T: std::convert::Into<crate::model::symptom::SymptomType>>(
        mut self,
        v: T,
    ) -> Self {
        self.symptom_type = v.into();
        self
    }

    /// Sets the value of [details][crate::model::Symptom::details].
    pub fn set_details<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.details = v.into();
        self
    }

    /// Sets the value of [worker_id][crate::model::Symptom::worker_id].
    pub fn set_worker_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.worker_id = v.into();
        self
    }
}

impl wkt::message::Message for Symptom {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.Symptom"
    }
}

/// Defines additional types related to [Symptom].
pub mod symptom {
    #[allow(unused_imports)]
    use super::*;

    /// SymptomType represents the different types of Symptoms that a TPU can be
    /// at.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum SymptomType {
        /// Unspecified symptom.
        Unspecified,
        /// TPU VM memory is low.
        LowMemory,
        /// TPU runtime is out of memory.
        OutOfMemory,
        /// TPU runtime execution has timed out.
        ExecuteTimedOut,
        /// TPU runtime fails to construct a mesh that recognizes each TPU device's
        /// neighbors.
        MeshBuildFail,
        /// TPU HBM is out of memory.
        HbmOutOfMemory,
        /// Abusive behaviors have been identified on the current project.
        ProjectAbuse,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [SymptomType::value] or
        /// [SymptomType::name].
        UnknownValue(symptom_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod symptom_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl SymptomType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::LowMemory => std::option::Option::Some(1),
                Self::OutOfMemory => std::option::Option::Some(2),
                Self::ExecuteTimedOut => std::option::Option::Some(3),
                Self::MeshBuildFail => std::option::Option::Some(4),
                Self::HbmOutOfMemory => std::option::Option::Some(5),
                Self::ProjectAbuse => std::option::Option::Some(6),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("SYMPTOM_TYPE_UNSPECIFIED"),
                Self::LowMemory => std::option::Option::Some("LOW_MEMORY"),
                Self::OutOfMemory => std::option::Option::Some("OUT_OF_MEMORY"),
                Self::ExecuteTimedOut => std::option::Option::Some("EXECUTE_TIMED_OUT"),
                Self::MeshBuildFail => std::option::Option::Some("MESH_BUILD_FAIL"),
                Self::HbmOutOfMemory => std::option::Option::Some("HBM_OUT_OF_MEMORY"),
                Self::ProjectAbuse => std::option::Option::Some("PROJECT_ABUSE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for SymptomType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for SymptomType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for SymptomType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::LowMemory,
                2 => Self::OutOfMemory,
                3 => Self::ExecuteTimedOut,
                4 => Self::MeshBuildFail,
                5 => Self::HbmOutOfMemory,
                6 => Self::ProjectAbuse,
                _ => Self::UnknownValue(symptom_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for SymptomType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "SYMPTOM_TYPE_UNSPECIFIED" => Self::Unspecified,
                "LOW_MEMORY" => Self::LowMemory,
                "OUT_OF_MEMORY" => Self::OutOfMemory,
                "EXECUTE_TIMED_OUT" => Self::ExecuteTimedOut,
                "MESH_BUILD_FAIL" => Self::MeshBuildFail,
                "HBM_OUT_OF_MEMORY" => Self::HbmOutOfMemory,
                "PROJECT_ABUSE" => Self::ProjectAbuse,
                _ => Self::UnknownValue(symptom_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for SymptomType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::LowMemory => serializer.serialize_i32(1),
                Self::OutOfMemory => serializer.serialize_i32(2),
                Self::ExecuteTimedOut => serializer.serialize_i32(3),
                Self::MeshBuildFail => serializer.serialize_i32(4),
                Self::HbmOutOfMemory => serializer.serialize_i32(5),
                Self::ProjectAbuse => serializer.serialize_i32(6),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for SymptomType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SymptomType>::new(
                ".google.cloud.tpu.v2.Symptom.SymptomType",
            ))
        }
    }
}

/// Request for [GetGuestAttributes][google.cloud.tpu.v2.Tpu.GetGuestAttributes].
///
/// [google.cloud.tpu.v2.Tpu.GetGuestAttributes]: crate::client::Tpu::get_guest_attributes
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetGuestAttributesRequest {
    /// Required. The resource name.
    pub name: std::string::String,

    /// The guest attributes path to be queried.
    pub query_path: std::string::String,

    /// The 0-based worker ID. If it is empty, all workers' GuestAttributes will be
    /// returned.
    pub worker_ids: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetGuestAttributesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetGuestAttributesRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [query_path][crate::model::GetGuestAttributesRequest::query_path].
    pub fn set_query_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.query_path = v.into();
        self
    }

    /// Sets the value of [worker_ids][crate::model::GetGuestAttributesRequest::worker_ids].
    pub fn set_worker_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.worker_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for GetGuestAttributesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GetGuestAttributesRequest"
    }
}

/// Response for
/// [GetGuestAttributes][google.cloud.tpu.v2.Tpu.GetGuestAttributes].
///
/// [google.cloud.tpu.v2.Tpu.GetGuestAttributes]: crate::client::Tpu::get_guest_attributes
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetGuestAttributesResponse {
    /// The guest attributes for the TPU workers.
    pub guest_attributes: std::vec::Vec<crate::model::GuestAttributes>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetGuestAttributesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [guest_attributes][crate::model::GetGuestAttributesResponse::guest_attributes].
    pub fn set_guest_attributes<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::GuestAttributes>,
    {
        use std::iter::Iterator;
        self.guest_attributes = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for GetGuestAttributesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.GetGuestAttributesResponse"
    }
}

/// A TPU accelerator configuration.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AcceleratorConfig {
    /// Required. Type of TPU.
    pub r#type: crate::model::accelerator_config::Type,

    /// Required. Topology of TPU in chips.
    pub topology: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AcceleratorConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [r#type][crate::model::AcceleratorConfig::type].
    pub fn set_type<T: std::convert::Into<crate::model::accelerator_config::Type>>(
        mut self,
        v: T,
    ) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [topology][crate::model::AcceleratorConfig::topology].
    pub fn set_topology<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.topology = v.into();
        self
    }
}

impl wkt::message::Message for AcceleratorConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.AcceleratorConfig"
    }
}

/// Defines additional types related to [AcceleratorConfig].
pub mod accelerator_config {
    #[allow(unused_imports)]
    use super::*;

    /// TPU type.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Type {
        /// Unspecified version.
        Unspecified,
        /// TPU v2.
        V2,
        /// TPU v3.
        V3,
        /// TPU v4.
        V4,
        /// TPU v5lite pod.
        V5LitePod,
        /// TPU v5p.
        V5P,
        /// TPU v6e.
        V6E,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Type::value] or
        /// [Type::name].
        UnknownValue(r#type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod r#type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Type {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::V2 => std::option::Option::Some(2),
                Self::V3 => std::option::Option::Some(4),
                Self::V4 => std::option::Option::Some(7),
                Self::V5LitePod => std::option::Option::Some(9),
                Self::V5P => std::option::Option::Some(10),
                Self::V6E => std::option::Option::Some(11),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
                Self::V2 => std::option::Option::Some("V2"),
                Self::V3 => std::option::Option::Some("V3"),
                Self::V4 => std::option::Option::Some("V4"),
                Self::V5LitePod => std::option::Option::Some("V5LITE_POD"),
                Self::V5P => std::option::Option::Some("V5P"),
                Self::V6E => std::option::Option::Some("V6E"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Type {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Type {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Type {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                2 => Self::V2,
                4 => Self::V3,
                7 => Self::V4,
                9 => Self::V5LitePod,
                10 => Self::V5P,
                11 => Self::V6E,
                _ => Self::UnknownValue(r#type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Type {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "TYPE_UNSPECIFIED" => Self::Unspecified,
                "V2" => Self::V2,
                "V3" => Self::V3,
                "V4" => Self::V4,
                "V5LITE_POD" => Self::V5LitePod,
                "V5P" => Self::V5P,
                "V6E" => Self::V6E,
                _ => Self::UnknownValue(r#type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Type {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::V2 => serializer.serialize_i32(2),
                Self::V3 => serializer.serialize_i32(4),
                Self::V4 => serializer.serialize_i32(7),
                Self::V5LitePod => serializer.serialize_i32(9),
                Self::V5P => serializer.serialize_i32(10),
                Self::V6E => serializer.serialize_i32(11),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Type {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
                ".google.cloud.tpu.v2.AcceleratorConfig.Type",
            ))
        }
    }
}

/// A set of Shielded Instance options.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ShieldedInstanceConfig {
    /// Defines whether the instance has Secure Boot enabled.
    pub enable_secure_boot: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ShieldedInstanceConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [enable_secure_boot][crate::model::ShieldedInstanceConfig::enable_secure_boot].
    pub fn set_enable_secure_boot<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.enable_secure_boot = v.into();
        self
    }
}

impl wkt::message::Message for ShieldedInstanceConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.tpu.v2.ShieldedInstanceConfig"
    }
}
